using System;
using FluentNHibernate.Automapping;
using FluentNHibernate.Automapping.Alterations;
using MvcMall.Core.Domains;
using MvcMall.Core.Enums;

namespace MvcMall.Data.NHibernateMaps
{
    public class StoreMap : IAutoMappingOverride<Store>
    {
        public void Override(AutoMapping<Store> mapping)
        {
            mapping.Id(c => c.Id).Column("StoreId").GeneratedBy.Foreign("User");
            mapping.Map(c => c.StoreStatus).CustomType(typeof(StoreStatus));
            mapping.Map(c => c.StoreType).CustomType(typeof(StoreType));

            mapping.HasOne(m => m.User).Cascade.All().Constrained();
            mapping.References(c => c.StoreGrade).Column("StoreGradeId");
            mapping.References(c => c.StoreCat).Column("CatId");
            mapping.References(c => c.PromoteUser).Column("PromoteUser");
            mapping.HasMany(c => c.StoreCategories);
            mapping.HasMany(c => c.StoreShippings);
            mapping.HasMany(c => c.StoreQualifications);
            mapping.HasMany(c => c.GoodsBrands);
            mapping.HasMany(c => c.Goodses);
        }
    }
}